﻿//重定向main页面中Iframe的src
function iframesrc(url) {

    var ifm = document.getElementById("mainiframe");
    ifm.src = url + "&temp=" + Math.random();
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function checkIE() {
    //浏览器嗅探技术
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 0;
    
    if (Sys.ie) return Sys.ie;
}



//----------控制页面高度
var height = document.documentElement.clientHeight;
var width = document.documentElement.clientWidth;

function adapting() {
    var resut = checkIE();
    var main = document.getElementById("main");
    var menu_conent = document.getElementById("menu_conent");
    var leftmenu = document.getElementById("leftmenu1_TreeView1");
    var conent = document.getElementById("conent");
    var switchPoint = document.getElementById("switchPoint");
    var right = document.getElementById("right");
    var conent_body = document.getElementById("conent_body");
    var mainiframe = document.getElementById("mainiframe");
    main.style.height = String(height - 83) + "px";
    menu_conent.style.height = String(height - 143) + "px";
    leftmenu.style.height = String(height - 143) + "px";
    conent.style.height = String(height - 103) + "px";
    conent.style.width = String(width - 203) + "px";
    switchPoint.style.marginTop = String(height - 133) / 2 + "px";
    right.style.marginLeft = 200 + "px";
    conent_body.style.width = String(width - 208) + "px";
    conent_body.style.height = String(height - 113) + "px";
    mainiframe.style.height = String(height - 113) + "px";
};

//----------展开/关闭左菜单
var ifshow = 1;
function switchSysBar() {
    var speed = 500;
    var right = document.getElementById("right");
    var conent = document.getElementById("conent");
    var left = document.getElementById("left");
    if (ifshow == 1) {
        document.getElementById("img1").src = "/themes/default/images/main_41_1.gif";
        $("#menu").animate({ width: 0 }, speed, function() { document.getElementById("menu").style.display = "none"; });
        $(right).animate({ marginLeft: 9 + "px" }, speed, function() { });
        $(conent).animate({ width: String(width - 12) + "px" }, speed, function() { left.style.left = 0 + "px"; });        
        $("#conent_body").animate({ width: String(width - 37) + "px" }, speed, function() { });
        $("#menutitle").animate({ width: 0 }, speed, function() { });
        ifshow = 0;
    }
    else {
        document.getElementById("img1").src = "/themes/default/images/main_41.gif";
        document.getElementById("menu").style.display = "";
        left.style.left = 3 + "px";
        $("#menu").animate({ width: 188 + "px" }, speed, function() { });        
        $(conent).animate({ width: String(width - 203) + "px" }, speed, function() { });        
        $("#conent_body").animate({ width: String(width - 228) + "px" }, speed, function() { });        
        $(right).animate({ marginLeft : 200 + "px" }, speed, function() { });
        $("#menutitle").animate({ width: 188 + "px" }, speed, function() {  });
        ifshow = 1;
    }
}

function winResize() {
    var resut = checkIE();
    var height = document.documentElement.clientHeight;
    var width = document.documentElement.clientWidth;
    var main = document.getElementById("main");
    var menu_conent = document.getElementById("menu_conent");
    var leftmenu = document.getElementById("leftmenu1_TreeView1");
    var conent = document.getElementById("conent");
    var switchPoint = document.getElementById("switchPoint");
    var right = document.getElementById("right");
    main.style.height = String(height - 83) + "px";
    menu_conent.style.height = String(height - 143) + "px";
    leftmenu.style.height = String(height - 143) + "px";
    conent.style.height = String(height - 103) + "px";
    conent.style.width = String(width - 203) + "px";
    switchPoint.style.marginTop = String(height - 133) / 2 + "px";
    right.style.marginLeft = 200 + "px";
    document.getElementById("conent_body").style.width = String(width - 228) + "px";
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//HTML加载完毕事件
window.onresize = winResize;

$(function() {
    adapting(); //自适应窗口大小
});

//后台刷新
function ReLoad() {
    iframesrc($("#mainiframe")[0].src);
}